/*
 * Level.h
 *
 *  Created on: 15 févr. 2011
 *      Author: seeme
 *      Défini un niveau/environement
 *      il embarque un graph de scène et la liste
 *      des ressources nécessaires.
 *      Sérializable.
 */

#ifndef LEVEL_H_
#define LEVEL_H_

#include "../TextBased/AbstractXMLResource.h"
#include <list>
#include "../../../Scene/Entity/StaticDrawableEntity.h"
#include "../../../Scene/Lights/AbstractLight.h"
#include "../../../Scene/Lights/OmniLight.h"
#include "../../../Scene/Lights/AmbiantLight.h"
#include "../../../Tools/Graph/sNode.h"
#include <fstream>

//To use HANDLE
#include "../../ResCache.h"

class Level: public AbstractXMLResource{
public:
	Level(std::string name, std::string path):AbstractXMLResource(name, path), m_ambiant(NULL){
		m_sceneGraph.setValue(NULL), m_size = 0;
	};
	Level(){m_size = 0;}
	virtual ~Level();

	size_t getSize();

	bool create();
	void destroy();

	void addEntity(StaticDrawableEntity* entity);

	//DEBUG
	sNode<StaticDrawableEntity*>& getGraph(){return m_sceneGraph;}

	friend std::ostream& operator<<(std::ostream& out, const Level& lvl){
		lvl.print(out);
		return out;
	}

	virtual void print(std::ostream& o) const {
		m_sceneGraph.display(o);
	}

	std::vector<OmniLight*>& getOmniLights(){return m_omnis;}
	AmbiantLight* getAmbiantLight(){return m_ambiant;}

private:
	void delGraph(sNode<StaticDrawableEntity*>& node);
	sNode<StaticDrawableEntity*> m_sceneGraph;

	//TODO: ça devrait être dans le scene graph...
	std::vector<OmniLight*> m_omnis;
	AmbiantLight* m_ambiant;
};

#endif /* LEVEL_H_ */
